# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

PYTHON_COMPAT=( python3_{6,7,8,9} )

inherit desktop meson udev python-any-r1 gnome2-utils

DESCRIPTION="GUI Software to configure gaming mice"
HOMEPAGE="https://github.com/libratbag/piper"
SRC_URI="https://github.com/libratbag/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="test"
RESTRICT="!test? ( test )"

#REQUIRED_USE="${PYTHON_REQUIRED_USE}"

DEPEND="${PYTHON_DEPS}
	virtual/pkgconfig
"
RDEPEND="
	dev-libs/libevdev
	dev-python/python-evdev
	virtual/libudev
"

src_prepare() {
	default
#	sed '/default:/d' -i meson_options.txt || die
	python_fix_shebang .
}

pkg_setup() {
        python-any-r1_pkg_setup
}


src_configure() {
	#python_setup 'python3'
	local emesonargs=(
		-Dtests=$(usex test true false)
	)
	meson_src_configure
}

src_install(){
	default
	meson_src_install
	python_optimize "${ED}/usr/share/${PN}"
	python_optimize "${ED}"
	python_optimize
}

pkg_postinst() {
        xdg_desktop_database_update
        gnome2_icon_cache_update

}

pkg_postrm() {
        xdg_desktop_database_update
        gnome2_icon_cache_update
}


